package com.shiyo.spring.annotation;


import com.shiyo.spring.annotation.bean.Cat;
import com.shiyo.spring.annotation.config.AnnoImportXmlConfig;
import com.shiyo.spring.annotation.config.QuickStartConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AnnotationConfigApplication {
    public static void main(String[] args) {
        //直接使用注解配置
        ApplicationContext context = new AnnotationConfigApplicationContext(QuickStartConfiguration.class);
        Cat cat = context.getBean(Cat.class);
        System.out.println(cat);

        // xml中可间接引入注解配置
        ApplicationContext context1 = new ClassPathXmlApplicationContext("annotation/annotation-config.xml");
        Cat cat1 = context1.getBean(Cat.class);
        System.out.println(cat1);

        //注解中也可引入xml配置
        ApplicationContext context2 = new AnnotationConfigApplicationContext(AnnoImportXmlConfig.class);
        System.out.println(context2.getBean(Cat.class));
    }
}
